package com.cskaoyan.controller.kylan;

import com.cskaoyan.bean.SearchHistory;
import com.cskaoyan.bean.wxSearch.SearchIndexVO;
import com.cskaoyan.service.kylan.SearchService;
import com.cskaoyan.until.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("wx/search")
public class WxSearchController {

    @Autowired
    SearchService searchService;

    /**
     * 搜索index
     *
     * @return
     */
    @RequestMapping("index")
    public Result index() {
        SearchIndexVO searchIndexVO = searchService.getKeyWords();
        return Result.ok(searchIndexVO);
    }


    /**
     * 搜索提示
     *
     * @param keyword
     * @return
     */
    @RequestMapping("helper")
    public Result searchHelper(String keyword) {

        List<String> keywordList = searchService.getKeywordsHelper(keyword);

        return Result.ok(keywordList);
    }

    /**
     * 删除搜索历史
     * @return
     */
    @RequestMapping("clearhistory")
    public Result clearHistory() {

        searchService.deleteHistorySearch();

        return Result.ok();
    }
}
